package com.hbnu.iostream;

import java.io.File;

public class FileOperator2 {
    public static void main(String[] args) {
        String path = "C:" + File.separator +"Users" + File.separator +"TX" + File.separator +"IdeaProjects" + File.separator +"javalean" + File.separator +"src" + File.separator +"com" + File.separator +"hbnu" + File.separator +"iostream" + File.separator +"test.txt";

        File file = new File(path);

        if(file.exists()){      //如果文件存在
            boolean result = file.delete();
            if (result) {
                System.out.println("文件删除成功");
            }
            else {
                System.out.println("文件删除失败");
            }
        }
    }
}
